package com.gh.inheritance;

/**
 * @author M.G
 * @create 2022-12-08 15:45
 */
public class Manager extends Employee{
    private  double bonus;

    public Manager(String name, double salary, int year,int month,int day) {
        //必须是子类的第一条
        //此处作为子类的构造器，若没有像这样显示的调用父类的构造器，将自动调用父类的无参构造器
        //如果超类没有无参构造，并且此处又没有显示调用父类构造方法，就会报错
        //java: 无法将类 com.gh.inheritance.Employee中的构造器 Employee应用到给定类型;
        super(name, salary, year,month,day);
    }

    @Override
    public double getSalary() {
        double baseSalary = super.getSalary();
        return baseSalary+bonus;
    }

    public void setBonus(double b) {
        bonus = b;
    }

    public void raiseSalary(double byPercent){
        double raise = super.getSalary() * byPercent/100;
        double newSalary = super.getSalary()+raise;
        setSalary(newSalary);

    }
}
